package engine.graphics
{
	import flash.display3D.Context3D;
	import flash.display3D.IndexBuffer3D;
	import flash.display3D.VertexBuffer3D;
	
	import engine.graphics.shader.RxConstantBuffer;
	import engine.graphics.shader.RxShaderProgram;
	import engine.math.RxVector4;
	
	public class RxDebugRender
	{
		private var m_xAxisVertexBuffer:VertexBuffer3D;
		private var m_yAxisVertexBuffer:VertexBuffer3D;
		private var m_zAxisVertexBuffer:VertexBuffer3D;
		private var m_axesIndexBuffer:IndexBuffer3D;
		private var m_xAxisColor:RxVector4;
		private var m_yAxisColor:RxVector4;
		private var m_zAxisColor:RxVector4;
		private var m_cubeVertexBuffer:VertexBuffer3D;
		private var m_cubeIndexBuffer:IndexBuffer3D;
		private var m_debugShader:RxShaderProgram;
		private var m_vsConstBuffer:RxConstantBuffer;
		private var m_fsConstBuffer:RxConstantBuffer;
		
		public function RxDebugRender(param1:Context3D)
		{
			var _loc_2:Number = 0.25;
			var _loc_3:* = new Vector.<Number>([0, 0, 0, _loc_2, -0.1, -0.1, _loc_2, 0.1, -0.1, _loc_2, -0.1, 0.1, _loc_2, 0.1, 0.1, 1, -0.1, -0.1, 1, 0.1, -0.1, 1, -0.1, 0.1, 1, 0.1, 0.1]);
			var _loc_4:* = new Vector.<Number>([0, 0, 0, -0.1, _loc_2, -0.1, -0.1, _loc_2, 0.1, 0.1, _loc_2, -0.1, 0.1, _loc_2, 0.1, -0.1, 1, -0.1, -0.1, 1, 0.1, 0.1, 1, -0.1, 0.1, 1, 0.1]);
			var _loc_5:* = new Vector.<Number>([0, 0, 0, -0.1, -0.1, _loc_2, 0.1, -0.1, _loc_2, -0.1, 0.1, _loc_2, 0.1, 0.1, _loc_2, -0.1, -0.1, 1, 0.1, -0.1, 1, -0.1, 0.1, 1, 0.1, 0.1, 1]);
			this.m_xAxisVertexBuffer = param1.createVertexBuffer(9, 3);
			this.m_yAxisVertexBuffer = param1.createVertexBuffer(9, 3);
			this.m_zAxisVertexBuffer = param1.createVertexBuffer(9, 3);
			this.m_xAxisVertexBuffer.uploadFromVector(_loc_3, 0, 9);
			this.m_yAxisVertexBuffer.uploadFromVector(_loc_4, 0, 9);
			this.m_zAxisVertexBuffer.uploadFromVector(_loc_5, 0, 9);
			var _loc_6:* = new Vector.<uint>([0, 2, 1, 0, 4, 2, 0, 3, 4, 0, 1, 3, 1, 5, 3, 7, 3, 5, 3, 7, 4, 8, 4, 7, 4, 8, 2, 6, 2, 8, 2, 6, 1, 5, 1, 6, 5, 6, 7, 8, 7, 6]);
			this.m_axesIndexBuffer = param1.createIndexBuffer(42);
			this.m_axesIndexBuffer.uploadFromVector(_loc_6, 0, 42);
			this.m_xAxisColor = new RxVector4(1, 0, 0, 1);
			this.m_yAxisColor = new RxVector4(0, 1, 0, 1);
			this.m_zAxisColor = new RxVector4(0, 0, 1, 1);
			var _loc_7:* = new Vector.<Number>([-0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5]);
			this.m_cubeVertexBuffer = param1.createVertexBuffer(8, 3);
			this.m_cubeVertexBuffer.uploadFromVector(_loc_7, 0, 8);
			var _loc_8:* = new Vector.<uint>([3, 0, 1, 0, 3, 2, 7, 2, 3, 2, 7, 6, 5, 6, 7, 6, 5, 4, 1, 4, 5, 4, 1, 0, 2, 4, 0, 4, 2, 6, 1, 7, 3, 7, 1, 5]);
			this.m_cubeIndexBuffer = param1.createIndexBuffer(36);
			this.m_cubeIndexBuffer.uploadFromVector(_loc_8, 0, 36);
			var _loc_9:* = "m44 vt0, va0, vc0\n" + "m44 vt1, vt0, vc4\n" + "mul vt2.xy, vt1.xy, vc8.xy\n" + "mul vt3.xy, vt1.w, vc8.zw\n" + "add vt1.xy, vt2.xy, vt3.xy\n" + "mov op, vt1\n";
			var _loc_10:String = "mov oc, fc0";
			this.m_debugShader = new RxShaderProgram();
			this.m_debugShader.SetShaderCode(param1, _loc_9, _loc_10);
			this.m_vsConstBuffer = new RxConstantBuffer(9);
			this.m_fsConstBuffer = new RxConstantBuffer(1);
		}
	}
}